package psn.kiko.mapper.ddl.table;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 获取某张表每一列的详细描述信息,执行语句
 */
@Mapper
public interface DescribeMapper {
	/**
	 * @param schema 数据库名
	 * @param table 表名
	 * @return 返回该表每一列的信息描述
	 */
	@Select("<script>" +
			"       DESCRIBE\n" +
			"        <choose>\n" +
			"            <when test=\"schema == null or schema == ''\">\n" +
			"                ${table}\n" +
			"            </when>\n" +
			"            <otherwise>\n" +
			"                ${schema}.${table}\n" +
			"            </otherwise>\n" +
			"        </choose>" +
			"</script>")
	List<Map<String,String>> describe(@Param("schema") String schema , @Param("table") String table);
}
